package cn.ncu.service;

import cn.ncu.dao.ProvinceDao;
import cn.ncu.entity.Province;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author:Martina
 * @create:2020-07-15 16:04
 * @description:
 */
@Service
@Transactional
public class ProvinceServiceImpl implements ProvinceService{

    @Autowired
    private ProvinceDao provinceDao;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<Province> findByPage(Integer page, Integer rows) {

        int start = (page - 1) * rows;
        return provinceDao.findByPage(start,rows);
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public Integer findTotals() {
        return provinceDao.findTotals();
    }

    @Override
    public void save(Province province) {
        province.setPlacecounts(String.valueOf(0));
        provinceDao.save(province);
    }

    @Override
    public void delete(String id) {
        provinceDao.delete(id);
    }

    @Override
    public void update(Province province) {
        provinceDao.update(province);
    }

    @Override
    public Province findAll(String id) {
        return provinceDao.findAll(id);
    }

    @Override
    public Province findOne(String name) {
        return provinceDao.findOne(name);
    }
}
